﻿#include "Mapper_testDataByTime.h"

#include "DataBaseConnector.h"
#include "MapperTool.h"

#include <qdatetime.h>
#include <qvariant.h>
#include <qsqlquery.h>
#include <qsqlerror.h>

#include <qdebug.h>
Mapper_testDataByTime::Mapper_testDataByTime()
{

}

Mapper_testDataByTime::~Mapper_testDataByTime()
{

}

void Mapper_testDataByTime::record(int rtt,int rtt_ave,int bw,int bw_max,int rto)
{
  QString mysql="INSERT INTO "+string_dataBaseName+
                "("+string_rtt+","
                   +string_rtt_ave+","
                   +string_bw+","
                   +string_bw_max+","
                   +string_now+","
                   +string_rto+")"+
                " VALUES "+"("+QString::number(rtt)+","
                              +QString::number(rtt_ave)+","
                              +QString::number(bw)+","
                              +QString::number(bw_max)+","
                              +"'"+MapperTool::mysqlDateTimeString(QDateTime::currentDateTime())+"'"+","
                              +QString::number(rto)+
                              ")"+";";
  QSqlQuery query=dataBaseConnector->exec(mysql);

}

DataBaseConnector* Mapper_testDataByTime::getDataBaseConnector()const
{
  return dataBaseConnector;
}

Mapper_testDataByTime* Mapper_testDataByTime::setDataBaseConnector(DataBaseConnector* const dataBaseConnector)
{
  this->dataBaseConnector=dataBaseConnector;
  printInjection(this,dataBaseConnector);
  return this;
}

void Mapper_testDataByTime::objectAutoInjection(QHash<QString, QObject *> *objMap)
{
  setDataBaseConnector(getObjFromMap<DataBaseConnector>(objMap));
}
